package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseWebcast extends SQLiteOpenHelper {

	private String tableName=null;
	public final String ID="WebcastID";
	public final String MP4="WebcastMP4";
	public final String MP3="WebcastMP3";
	public final String FileDescription="WebcastFileDescription";
	public final String FileTitle="WebcastFileTitle";
	public final String CreateDate="WebcastCourseCreateDate";
	public final String CourseCode="WebcastCourseCode";
	
	public DatabaseWebcast(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ ID + " TEXT PRIMARY KEY , "+
				  MP4 + " TEXT, " + MP3 + " TEXT, " + FileDescription + " TEXT, " + FileTitle + 
				  " TEXT, " + CreateDate + " TEXT," + CourseCode + " TEXT)"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
